package question2;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NumberWords {
    public static int searchObjectWord(String word,String objWord){
        int count = 0;
       Pattern p = Pattern.compile(objWord);
        Matcher m = p.matcher(word);
        while(m.find()){
            count++;
        }
        return count;
    }

    public static void main(String[] args) {



        Scanner input = new Scanner(System.in);
        System.out.println("请输入你查询的文字");
        String word = input.nextLine();
        System.out.println("请输入你要查询的目标文字");
        String objW = input.nextLine();
       int count =  searchObjectWord(word,objW);
        System.out.println(objW+"一共出现了"+count+"次");
    }

}
